﻿using P2P.Main;
using P2P.Main.Model;
using P2P.Util;

namespace P2P.MainServer
{
    internal class Program
    {
        static void Main(string[] args) 
        {
            ConfigurationUtil.LoadConfig("App.config");

            var hosts = new Hosts
            {
                UDPMainServerFirstInternalIP = ConfigurationUtil.GetConfigValue<string>("udp.main.server.first.internal.ip"),
                UDPMainServerFirstInternalPort = ConfigurationUtil.GetConfigValue<int>("udp.main.server.first.internal.port"),
                UDPMainServerFirstPublicIP = ConfigurationUtil.GetConfigValue<string>("udp.main.server.first.public.ip"),
                UDPMainServerFirstPublicPort = ConfigurationUtil.GetConfigValue<int>("udp.main.server.first.public.port"),
                UDPMainServerSecondInternalIP = ConfigurationUtil.GetConfigValue<string>("udp.main.server.second.internal.ip"),
                UDPMainServerSecondInternalPort = ConfigurationUtil.GetConfigValue<int>("udp.main.server.second.internal.port"),
                UDPMainServerSecondPublicIP = ConfigurationUtil.GetConfigValue<string>("udp.main.server.second.public.ip"),
                UDPMainServerSecondPublicPort = ConfigurationUtil.GetConfigValue<int>("udp.main.server.second.public.port"),
                UDPTurnServerIP = ConfigurationUtil.GetConfigValue<string>("udp.turn.server.ip"),
                UDPTurnServerPort = ConfigurationUtil.GetConfigValue<int>("udp.turn.server.port"),
                UDPStunServerIP = ConfigurationUtil.GetConfigValue<string>("udp.stun.server.ip"),
                UDPStunServerPort = ConfigurationUtil.GetConfigValue<int>("udp.stun.server.port"),
                TCPMainServerInternalIP = ConfigurationUtil.GetConfigValue<string>("tcp.main.server.internal.ip"),
                TCPMainServerInternalPort = ConfigurationUtil.GetConfigValue<int>("tcp.main.server.internal.port"),
                TCPMainServerPublicIP = ConfigurationUtil.GetConfigValue<string>("tcp.main.server.public.ip"),
                TCPMainServerPublicPort = ConfigurationUtil.GetConfigValue<int>("tcp.main.server.public.port"),
                TCPTurnServerIP = ConfigurationUtil.GetConfigValue<string>("tcp.turn.server.ip"),
                TCPTurnServerPort = ConfigurationUtil.GetConfigValue<int>("tcp.turn.server.port"),
            };

            AppBuilder.Configure(hosts, ConfigurationUtil.GetConfigValue<long>("workerId"),
                ConfigurationUtil.GetConfigValue<long>("datacenterId"), ConfigurationUtil.GetConfigValue<int>("kbucketCount"), ConfigurationUtil.GetConfigValue<int>("kbucketCapacity"), ConfigurationUtil.GetConfigValue<string>("aes.key")).Start();

        }
    }
} 
